/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IClientDao;
import com.nxlv2.nomad.accessdb.dao.ICommandeDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcClientDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcCommandeDao;
import com.nxlv2.nomad.businessobjects.Adresse;
import com.nxlv2.nomad.businessobjects.Client;
import com.nxlv2.nomad.businessobjects.Commande;
import com.nxlv2.nomad.businessobjects.DetailCommande;
import com.nxlv2.nomad.businessobjects.Satisfaction;
import java.util.List;

/**
 *
 * @author Administrateur
 */
public class CommandeServices {
    private static final ICommandeDao dao = new JdbcCommandeDao();
    private static final IClientDao daoCl = new JdbcClientDao();
    
    /**
     * 
     * @param commande
     * @param client
     * @throws ServiceException 
     */
    public void create(Commande commande, Client client) throws ServiceException {
        dao.saveCommande(commande);
        daoCl.lierCommandeAClient(commande, client);
    }
    
    /**
     * 
     * @param commande
     * @throws ServiceException 
     */
    public void update(Commande commande) throws ServiceException {
        dao.updateCommande(commande);
    }
    
    /**
     * 
     * @param commande
     * @throws ServiceException 
     */
    public void delete(Commande commande) throws ServiceException {
        dao.deleteCommande(commande.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return Commande
     * @throws ServiceException 
     */
    public Commande get(int id) throws ServiceException {
        return dao.findCommandeById(id);
    }
    
    /**
     * 
     * @param commande
     * @return List<DetailCommande>
     * @throws ServiceException 
     */
    public List<DetailCommande> getDetailCommandes(Commande commande) throws ServiceException {
        return dao.getDetailCommandesParCommande(commande);
    }
    
        /**
     * 
     * @param commande
     * @return List<DetailCommande>
     * @throws ServiceException 
     */
    public List<DetailCommande> getDetailCommandesMaj(Commande commande) throws ServiceException {
        return dao.getDetailCommandesMajParCommande(commande);
    }
    
    /**
     * 
     * @param detailCommande
     * @param commande
     * @throws ServiceException 
     */
    public void linkDetailCommande (DetailCommande detailCommande, Commande commande) throws ServiceException {
        dao.lierDetailCommandeACommande(detailCommande, commande);
    }
    
    /**
     * 
     * @param commande
     * @return List<Satisfaction>
     * @throws ServiceException 
     */
    public List<Satisfaction> getSatisfactions(Commande commande) throws ServiceException {
        return dao.getSatisfactionParCommande(commande);
    }
    
    /**
     * 
     * @param satisfaction
     * @param commande
     * @throws ServiceException 
     */
    public void linkSatisfaction(Satisfaction satisfaction, Commande commande) throws ServiceException {
        dao.lierSatisfactionACommande(satisfaction, commande);
    }    
}
